package cn.itcast.hotel.controller;

import cn.itcast.hotel.common.PageResult;
import cn.itcast.hotel.dto.HotelPageQueryDTO;
import cn.itcast.hotel.service.HotelService;
import cn.itcast.hotel.vo.HotelVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author liudo
 * @version 1.0
 * @project hotel-demo
 * @date 2023/10/27 16:02:57
 */
@RestController
@RequestMapping("/hotel")
public class HotelController {

    @Autowired
    private HotelService hotelService;

    @PostMapping("/list")
    public PageResult<HotelVO> list(@RequestBody HotelPageQueryDTO hotelPageQueryDTO) {
        return hotelService.pageList(hotelPageQueryDTO);
    }

    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody HotelPageQueryDTO hotelPageQueryDTO) {
        return hotelService.filters(hotelPageQueryDTO);
    }

    @GetMapping("/suggestion")
    public List<String> suggestion(String key) {
        return hotelService.suggestion(key);
    }
}
